//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    spinShow: false,
    exercisePaper: [],
  },
  onLoad: function() {
    this.setData({
      spinShow: true
    });
    this.indexLoad()
  },
  onPullDownRefresh() {
    this.setData({
      spinShow: true
    });
    if (!this.loading) {
      this.indexLoad()
    }
  },
  goPractice() {
    wx.navigateTo({
      url:'../exam/practice/practice'
    })
  },
  indexLoad: function() {
    let _this = this
    app.formPost('/api/wx/student/listExercise', null).then(res => {
      _this.setData({
        spinShow: false
      });
      wx.stopPullDownRefresh()
      if (res.code === 20000) {
        _this.setData({
          exercisePaper: res.data
        });
      }
    }).catch(e => {
      _this.setData({
        spinShow: false
      });
      app.message(e, 'error')
    })
  }
})